funcs_and_args for loop python

41

funcs_and_args = [(func1, "150mm"),
                  (func1, "100mm",
                  (func2, "50mm"),
                  (func3, "50mm"),]
                   
for func, arg in funcs_and_args :
    try:
        func(arg)
        # exit the loop on success
        break
    except ExplicitException:
        # repeat the loop on failure
        continue
else:
    # List exhausted without break, so there must have always been an Error
    raise Exception("Error text")

Comments

Submit
0 Comments